package com.momo.encoderHandler3;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * @author Kagome
 * @title: MyPersionEncoder
 * @projectName boot2.X-netty
 * @description: 解码器
 * @date 2019/6/2 16:11
 */
public class MyPersionEncoder extends MessageToByteEncoder<PersionProtocol> {
    @Override
    protected void encode(ChannelHandlerContext ctx, PersionProtocol msg, ByteBuf out) throws Exception {
        System.out.println("MyPersionEncoder 进入");
        out.writeInt(msg.getLength());
        out.writeBytes(msg.getContent());
    }
}
